# coding: utf-8

# -------------------------------------------------------------------------------
# Name:         user
# Description:
# Author:       XiangjunZhao
# EMAIL:        2419352654@qq.com
# Date:         2019-11-03
# -------------------------------------------------------------------------------
from rest_framework import serializers
from apps.HttpAutoTestService.models import User
from apps.HttpAutoTestService.serializers import BaseListSerializer, BaseSerializer

__all__ = ['UserNameListSerializer', 'UserListSerializer', 'UserSerializer']


class UserNameListSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = ('id', 'username', 'real_name')


class UserListSerializer(BaseListSerializer):
    class Meta:
        model = User
        fields = ('id', 'username', 'real_name', 'phone', 'gender', 'email', 'is_active', 'last_login', 'create_time',
                  'update_time', 'remark', 'modifier', 'is_system')


class UserSerializer(BaseSerializer):
    class Meta:
        model = User
        fields = ('id', 'username', 'real_name', 'phone', 'gender', 'email', 'is_active', 'is_deleted', 'last_login',
                  'create_time', 'update_time', 'remark', 'password', 'modifier')
        extra_kwargs = {
            'password': {'write_only': True}
        }
